package com.yfeng.common.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class PropertiesTool {

	private static final Log log = LogFactory.getLog(PropertiesTool.class);
	private static Properties propertie;

	public void init() {
		InputStream inputFile = PropertiesTool.class.getClassLoader()
				.getResourceAsStream("home.properties");
		propertie = new Properties();

		try {
			propertie.load(inputFile);			
			inputFile.close();
		} catch (IOException e) {

			log.error(e.getMessage(),e);
		}

	}

	public static String getValue(String key) {
		if (propertie.containsKey(key)) {
			String value = propertie.getProperty(key);
			return value;
		} else
			return "";
	}
	
	public static Object getValue(String key,String type) {
		if (propertie.containsKey(key)) {
			String value = propertie.getProperty(key);
			if(type.equals("int"))
				return Integer.parseInt(value);
			else
				return value;
		} else
			return "";
	}
}
